<?php

namespace App\Transformers\Admin;

use League\Fractal\TransformerAbstract;

class StudentResultTransformer extends TransformerAbstract
{
    public $types = ['', '正常试卷', '练习试卷', '闯关试卷'];

    public function transform($examination)
    {
        return [
            'id' => $examination->id,
            'name' => $examination->name,
            'category_name' => $examination->category->name,
            'type' => $this->types[$examination->type],
            'start_time' => $examination->start_time,
            'over_time' => $examination->over_time,
            'timer' => $examination->timer / 60,
            'peoples_num' => count(explode(',',trim($examination->peoples,",")))
        ];
    }
}

